package com.fr.report.cellElement;

import com.fr.base.XMLable;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;

public class CellGUIAttr
  implements XMLable
{
  public static final CellGUIAttr DEFAULT_CELLGUIATTR = new CellGUIAttr();
  private static final int PREVIEW_CONTENT = 2;
  private static final int PRINT_CONTENT = 4;
  private static final int PREVIEW_BACKGROUND = 8;
  private static final int PRINT_BACKGROUND = 16;
  private static final int PRINT_ZERO = 32;
  private static final int PREVIEW_BORDER = 64;
  private static final int PRINT_BORDER = 128;
  private static final int AUTO_SHRINK_TO_FIT_0 = 256;
  private static final int AUTO_SHRINK_TO_FIT_1 = 512;
  private static final int NOT_SHOW_AS_IMAGE = 1024;
  private static final int NOT_SHOW_AS_HTML = 2048;
  private String tooltipText = null;
  private short style = 4095;

  public String getTooltipText()
  {
    return this.tooltipText;
  }

  public void setTooltipText(String paramString)
  {
    this.tooltipText = paramString;
  }

  public void setAdjustMode(int paramInt)
  {
    if (paramInt == 3)
    {
      CellGUIAttr tmp6_5 = this;
      tmp6_5.style = (short)(tmp6_5.style | 0x100);
      CellGUIAttr tmp19_18 = this;
      tmp19_18.style = (short)(tmp19_18.style | 0x200);
    }
    else if (paramInt == 2)
    {
      CellGUIAttr tmp40_39 = this;
      tmp40_39.style = (short)(tmp40_39.style & 0xFFFFFEFF);
      CellGUIAttr tmp53_52 = this;
      tmp53_52.style = (short)(tmp53_52.style | 0x200);
    }
    else if (paramInt == 1)
    {
      CellGUIAttr tmp74_73 = this;
      tmp74_73.style = (short)(tmp74_73.style | 0x100);
      CellGUIAttr tmp87_86 = this;
      tmp87_86.style = (short)(tmp87_86.style & 0xFFFFFDFF);
    }
    else
    {
      CellGUIAttr tmp103_102 = this;
      tmp103_102.style = (short)(tmp103_102.style & 0xFFFFFEFF);
      CellGUIAttr tmp116_115 = this;
      tmp116_115.style = (short)(tmp116_115.style & 0xFFFFFDFF);
    }
  }

  public int getAdjustMode()
  {
    int i = 0;
    if ((this.style & 0x200) != 0)
      i += 2;
    if ((this.style & 0x100) != 0)
      ++i;
    return i;
  }

  public boolean isPreviewContent()
  {
    return ((this.style & 0x2) != 0);
  }

  public void setPreviewContent(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x2);
    }
    else
    {
      CellGUIAttr tmp19_18 = this;
      tmp19_18.style = (short)(tmp19_18.style & 0xFFFFFFFD);
    }
  }

  public boolean isPrintContent()
  {
    return ((this.style & 0x4) != 0);
  }

  public void setPrintContent(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x4);
    }
    else
    {
      CellGUIAttr tmp19_18 = this;
      tmp19_18.style = (short)(tmp19_18.style & 0xFFFFFFFB);
    }
  }

  public boolean isPreviewBackground()
  {
    return ((this.style & 0x8) != 0);
  }

  public void setPreviewBackground(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x8);
    }
    else
    {
      CellGUIAttr tmp20_19 = this;
      tmp20_19.style = (short)(tmp20_19.style & 0xFFFFFFF7);
    }
  }

  public boolean isPrintBackground()
  {
    return ((this.style & 0x10) != 0);
  }

  public void setPrintBackground(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x10);
    }
    else
    {
      CellGUIAttr tmp20_19 = this;
      tmp20_19.style = (short)(tmp20_19.style & 0xFFFFFFEF);
    }
  }

  public boolean isPrintZeroValue()
  {
    return ((this.style & 0x20) != 0);
  }

  public void setPrintZeroValue(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x20);
    }
    else
    {
      CellGUIAttr tmp20_19 = this;
      tmp20_19.style = (short)(tmp20_19.style & 0xFFFFFFDF);
    }
  }

  public boolean isPreviewBorder()
  {
    return ((this.style & 0x40) != 0);
  }

  public void setPreviewBorder(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x40);
    }
    else
    {
      CellGUIAttr tmp20_19 = this;
      tmp20_19.style = (short)(tmp20_19.style & 0xFFFFFFBF);
    }
  }

  public boolean isPrintBorder()
  {
    return ((this.style & 0x80) != 0);
  }

  public void setPrintBorder(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x80);
    }
    else
    {
      CellGUIAttr tmp21_20 = this;
      tmp21_20.style = (short)(tmp21_20.style & 0xFFFFFF7F);
    }
  }

  public boolean isShowAsImage()
  {
    return ((this.style & 0x400) == 0);
  }

  public void setShowAsImage(boolean paramBoolean)
  {
    if (!(paramBoolean))
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x400);
    }
    else
    {
      CellGUIAttr tmp21_20 = this;
      tmp21_20.style = (short)(tmp21_20.style & 0xFFFFFBFF);
    }
  }

  public boolean isShowAsHTML()
  {
    return ((this.style & 0x800) == 0);
  }

  public void setShowAsHTML(boolean paramBoolean)
  {
    if (!(paramBoolean))
    {
      CellGUIAttr tmp5_4 = this;
      tmp5_4.style = (short)(tmp5_4.style | 0x800);
    }
    else
    {
      CellGUIAttr tmp21_20 = this;
      tmp21_20.style = (short)(tmp21_20.style & 0xFFFFF7FF);
    }
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    String str;
    if (paramXMLableReader.isAttr())
    {
      if ((str = paramXMLableReader.getAttr("autoAdjustRowHeight")) != null)
        if (Integer.parseInt(str) == 0)
          setAdjustMode(3);
        else if (Integer.parseInt(str) == 1)
          setAdjustMode(1);
        else if (Integer.parseInt(str) == 2)
          setAdjustMode(0);
      if (((str = paramXMLableReader.getAttr("autoRowHeight")) == null) || ((str != null) && (Boolean.valueOf(str).booleanValue())))
        setAdjustMode(3);
      else if (((str = paramXMLableReader.getAttr("trueRowHeight")) == null) || ((str != null) && (Boolean.valueOf(str).booleanValue())))
        setAdjustMode(1);
      else
        setAdjustMode(0);
      if ((str = paramXMLableReader.getAttr("adjustmode")) != null)
        setAdjustMode(Integer.parseInt(str));
      if ((str = paramXMLableReader.getAttr("previewBackground")) != null)
        setPreviewBackground(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("previewBorder")) != null)
        setPreviewBorder(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("previewContent")) != null)
        setPreviewContent(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("printBackground")) != null)
        setPrintBackground(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("printBorder")) != null)
        setPrintBorder(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("printContent")) != null)
        setPrintContent(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("printZeroValue")) != null)
        setPrintZeroValue(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("showAsImage")) != null)
        setShowAsImage(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("showAsHTML")) != null)
        setShowAsHTML(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("visible")) != null)
        setPreviewContent(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("style")) != null)
      {
        this.style = (short)Integer.parseInt(str);
        if (this.style >= 1024)
          setAdjustMode(1);
        else
          setAdjustMode(3);
      }
    }
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("ToolTipText")))
      if ((str = paramXMLableReader.getElementValue()) != null)
        setTooltipText(str);
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("CellGUIAttr");
    if (getAdjustMode() != 3)
      paramXMLPrintWriter.attr("adjustmode", getAdjustMode());
    if (!(isPreviewBackground()))
      paramXMLPrintWriter.attr("previewBackground", "false");
    if (!(isPreviewBorder()))
      paramXMLPrintWriter.attr("previewBorder", "false");
    if (!(isPreviewContent()))
      paramXMLPrintWriter.attr("previewContent", "false");
    if (!(isPrintBackground()))
      paramXMLPrintWriter.attr("printBackground", "false");
    if (!(isPrintBorder()))
      paramXMLPrintWriter.attr("printBorder", "false");
    if (!(isPrintContent()))
      paramXMLPrintWriter.attr("printContent", "false");
    if (!(isPrintZeroValue()))
      paramXMLPrintWriter.attr("printZeroValue", "false");
    if (isShowAsImage())
      paramXMLPrintWriter.attr("showAsImage", "true");
    if (isShowAsHTML())
      paramXMLPrintWriter.attr("showAsHTML", "true");
    if (getTooltipText() != null)
      paramXMLPrintWriter.startTAG("ToolTipText").textNode(getTooltipText()).end();
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof CellGUIAttr))
      return false;
    CellGUIAttr localCellGUIAttr = (CellGUIAttr)paramObject;
    return ((this.style == localCellGUIAttr.style) && (ComparatorUtils.equals(this.tooltipText, localCellGUIAttr.tooltipText)));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    CellGUIAttr localCellGUIAttr = (CellGUIAttr)super.clone();
    return localCellGUIAttr;
  }
}